import { request } from "umi";

export async function listWarehouseByPage(body: RequestParam<API.WarehouseDTO>, options?: { [key: string]: any }){
  return request<BaseResponse<IPage<API.WarehouseVO>>>('/api/warehouse/list',{
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
    },
    data: body,
  })
}

export async function addWarehouse(body: RequestParam<API.WarehouseDTO>){
  return request<BaseResponse<IPage<API.WarehouseVO>>>('/api/warehouse/add',{
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
    },
    data: body,
  })
}

export async function updateWarehouse(body: API.WarehouseDTO){
  return request<BaseResponse<boolean>>('/api/warehouse/update',{
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
    },
    data: body,
  })
}

export async function deleteWarehouse(id: string){
  return request<BaseResponse<boolean>>('/api/warehouse/delete',{
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
    },
    data: {id: id}
  });
}

// 获取仓库列表接口
export async function getWarehouseList(options?: { [key: string]: any }) {
  return request<BaseResponse<API.WarehouseVO[]>>('/api/warehouse/listAll', {
    method: 'GET',
    headers: {
      'Content-Type': 'application/json',
    },
    ...(options || {}),
  });
}
